<div class="row">
	<div class="col-md-12">
		<form id="form">
            <input type="hidden" name="id" value="${bean.id}">
			<div class="modal-body">
				<div class="form-group" >
					<label id="nameLabel">菜单名称</label>
					<input type="text" class="form-control" name="name" id="name" placeholder="输入菜单名称" value="${bean.name!}">
				</div>
				<div class="form-group">
					<label>菜单类型</label>
                    <select id="type" name="type" class="form-control" style="width: 100%;" onchange="change()">
                        <option value="click" <#if bean.type == 'click'>selected</#if> >消息响应</option>
                        <option value="view" <#if bean.type == 'view'>selected</#if> >网页链接</option>
                    </select>
				</div>
				<div class="form-group" id="url" style="<#if bean.type =='view'>display:block<#else>display:none</#if>">
					<label>URL</label>
                   <input type="text" class="form-control" name="url" value="${bean.url!}">
				</div>
                <div class="form-group">
                    <label>菜单位置</label>
                    <select name="orders" class="form-control" style="width: 100%;">
                        <#list ordersList as item>
                            <option value="${item.value}" <#if item.value == bean.orders>selected</#if> ><#if item.value?length ==2>└─</#if>${item.name!}</option>
                        </#list>
                    </select>
                </div>
                <div class="form-group">
                    <label>是否显示</label>
                    <select name="status" class="form-control select2" style="width: 100%;">
                        <option value="1" <#if bean.status == 1>selected</#if> >是</option>
                        <option value="0" <#if bean.status == 0>selected</#if> >否</option>
                    </select>
                </div>
			</div>
			<div class="modal-footer">
				<div class="pull-right">
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i>关闭</button>
					<button type="button" class="btn btn-primary btn-sm" onclick="menuformSave()"><i class="fa fa-save"></i>保存</button>
				</div>
			</div>
		</form>
	</div>
</div>

<script type="text/javascript">

   var menuformSave =  function (){
        $("span").remove(".errorClass");
        $("br").remove(".errorClass");
        var status = 1;
        if($("#name").val()==""){
            $("#nameLabel").prepend('<span class="errorClass" style="color:red">*菜单名称不能为空</span><br class="errorClass"/>');
            status = 0;
        }

        if(status == 0){
            return false;
        }else{
            $.ajax({
                url: '/admin/wx/menu/save',
                type: 'post',
                dataType: 'json',
                data: $("#form").serialize(),
                success: function (data) {
                    if (data.code == 0){
                        $("#lgModal").modal('hide');
                        alertMsg("添加成功","success");
                        tbReload();
                    }
                }
            });
        }
    }

    function change() {
        if ($("#type").val() == 'view'){
            $("#url").css("display","block");
        }else {
            $("#url").css("display","none");
        }
    }


</script>